# coding=utf-8
'''
author : 董新强
description : 调用异步方法
'''
from concurrent.futures.thread import ThreadPoolExecutor
from functools import partial

from tornado.ioloop import IOLoop

__thread_pool__ = ThreadPoolExecutor(32)


async def run_async(func, *args, **kwargs):
    """
    异步执行阻塞方法
    :param func: 方法或函数
    :param args: 位置变量
    :param kwargs: 关键字变量
    """
    return await IOLoop.current().run_in_executor(__thread_pool__, partial(func, *args, **kwargs))
